package com.yingxin.yxerp.module.sys.controller;

import com.yingxin.yx.framework.commons.id.IdHelper;
import com.yingxin.yxerp.module.sys.service.ITradeManagementInvoiceNameSettingService;
import com.yingxin.yxerp.module.sys.vo.req.OtherSetCreateVo;
import com.yingxin.yxerp.module.sys.vo.req.OtherSetQueryVo;
import com.yingxin.yxerp.module.sys.vo.resp.OtherSetRespVo;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 贸易管理开票名称设置 前端控制器
 * @author yuebao
 * @since 2023-12-28
 */

@RestController
@RequestMapping("/trade/management/invoice/name/setting")
public class TradeManagementInvoiceNameSettingController {

    @Autowired
    private ITradeManagementInvoiceNameSettingService service;

    @ApiOperation(value = "查询列表-全部")
    @PostMapping("/list")
    public List<OtherSetRespVo> list(@RequestBody OtherSetQueryVo queryVo) {
        return service.listVo( queryVo );
    }

    @ApiOperation(value = "根据id查询")
    @GetMapping("/{id}")
    public OtherSetRespVo get(@PathVariable("id") String id) {
        return service.getVo( id );
    }

    @ApiOperation(value = "创建")
    @PostMapping("/create")
    public String create(@RequestBody OtherSetCreateVo createVo) {
        createVo.setId( IdHelper.snowflakeId() );
        service.create( createVo );
        return createVo.getId();
    }

    @ApiOperation(value = "编辑")
    @PostMapping("/update")
    public String update(@RequestBody OtherSetCreateVo createVo) {
        service.update( createVo );
        return createVo.getId();
    }

    @ApiOperation(value = "删除")
    @GetMapping("/delete/{id}")
    public void delete(@PathVariable("id") String id) {
        service.delete( id );
    }

}
